import rarfile
import os
import os
import rarfile


def unrar_folder(rar_path, extract_path):
    """
    解压指定的RAR文件到指定的路径。

    :param rar_path: RAR文件的路径
    :param extract_path: 解压到的目标路径
    """
    try:
        with rarfile.RarFile(rar_path) as rf:
            rf.extractall(extract_path)
        print(f"成功解压 {rar_path} 到 {extract_path}")
    except rarfile.BadRarFile as e:
        print(f"RAR文件损坏: {e}")
    except FileNotFoundError as e:
        print(f"文件未找到: {e}")
    except Exception as e:
        print(f"解压过程中出现其他错误: {e}")


if __name__ == "__main__":
    rar_path = "data/11班.rar"  # 替换为实际的RAR压缩文件夹路径
    extract_path = "data/11班"  # 替换为解压后的文件夹路径
    unrar_folder(rar_path, extract_path)